This README file describes how to reproduce the figures of the paper
'High-frequency plasma waves and pitch-angle scattering induced by pulsed electron beams'
by G.L. Delzanno and V. Roytershteyn.

---------------------------------------------------- 
Figure 1 is obtained with the following files:
  
Left panel:
dP_dwvsw_theory_whistler_mode.xlsx
This is the power spectral density as a function of frequency for different beam energies 
(2, 15, 30 keV) in the whistler branch (w<wce).

Right panel:
dP_dwvsw_theory_X_mode.xlsx
This is the power spectral density as a function of frequency for different beam energies  
(2, 15, 30 keV) in the X-mode branch (w>wce).

Assuming that the data is downloaded as *.xlsx files, the Matlab script read_figure1.m recreates Figure 1.

----------------------------------------------------
Figure 2 and 3 are obtained with the following files:

The provided binary files correspond to the Fourier components of the electromagnetic field 
in the SPS simulation of a charge pulse with energy 15keV. Each component of the field (e.g. 
B_x, B_y, B_z for x,y,z components of magnetic field B and E_x,E_y,E_z for components of 
the electric field E) are stored in a seperate file with naming convention "Q_XXXX.bin", 
where Q stands for the field component (e.g. "bx") and XXXX is the simulation step. Each file 
is a simple block-binary of double-precision complex numbers stored as a sequence of 
(real_part,complex_part),(real_part,complex_part)... in a column-major (FORTRAN) ordering.

The spatial resolution of the simulation is Nx = 399, Ny = 399, Nz = 249 (dealiased) Fourier modes. 
The fields used here are from simulation time step 1216, corresponding to time t*wpe=76.

Two scripts are provided to illustrate how to handles the fiels:

compute_fields_phys_space.m is an OCTAVE/MATLAB script that reads the supplied binary fiels and 
performs 3D Fast Fourier Transform (FFT) to compute physical-space representation of the fields 
(stored as a single-precision binary).

make_fig2.py is a python script that reproduces Fig. 2 from the publication and illustrates how 
to handle both the complex and real-space files in python.

----------------------------------------------------
Figure 4 is obtained with the following files:

Left panel:	
PvsEb_theory_whistler_mode.xlsx
This is the total radiated power versus beam energy for point pulses with pitch angle 0.01 and 0.001 degrees and for a Gaussian
pulse with pitch angle 0.001 degrees, all in the whistler branch (w<wce).

PvsEb_simulations_whistler_mode.xlsx
This is the total radiated power versus beam energy for the fluid-kinetic simulations with the SPS code for a 
field-aligned Gaussian pulse and for beam energies 2, 5, 15, 30 keV, all in the whistler branch (w<wce).

Right panel:
PvsEb_theory_X_mode.xlsx
This is the total radiated power versus beam energy for point pulses with pitch angle 0.01 and 0.001 degrees and for a Gaussian
pulse with pitch angle 0.001 degrees, all in the X-mode branch (w>wce).

PvsEb_simulations_X_mode.xlsx
This is the total radiated power versus beam energy for the fluid-kinetic simulations with the SPS code for a 
field-aligned Gaussian pulse and for beam energies 2, 5, 15, 30, 100 keV, all in the X-mode branch (w>wce).

Assuming that the data is downloaded as *.xlsx files, the Matlab script read_figure4.m recreates Figure 4.

----------------------------------------------------
Figure 5 is obtained with the following files:
LfieldvsQb.xlsx
This is the estimated axial extent (in meters) of the radiated wave field versus beam pulse charge 
(|qb|) for a beam with Eb=15 keV and three cases corresponding to
(1) Initial radial velocity Vr(0)=0 for a beam in vacuum
(2) Initial radial velocity Vr(0)=1.2e7 m/s for a beam in vacuum
(3) a fully neutralized beam, qb^eff=0, for Vr(0)=0

Assuming that the data is downloaded as *.xlsx files, the Matlab script read_figure5.m recreates Figure 5.

----------------------------------------------------
Figure 6 is obtained with the following files:
pitch_angle_scattering.xlsx

This is the number of electrons versus pitch angle at the end of four test-particle simulations (t=0.4 ms) corresponding to
(1) w=2.1wce, s=1, E(0)=39 keV
(2) w=2.1wce, s=-3, E(0)=1.15 MeV
(3) w=0.597wce, s=1, E(0)=39 keV
(4) w=0.126wce, s=1, E(0)=1.15 meV

Assuming that the data is downloaded as *.xlsx files, the Matlab script read_figure6.m recreates Figure 6.

---------------------
TAB-DELIMITED FORMAT|
---------------------
The data can also be downloaded in tab-delimited format, in which case one should replace lines like this
(example for Figure 1)

B = xlsread('dP_dwvsw_theory_X_mode.xlsx');

with lines like

B = importdata('dP_dwvsw_theory_X_mode.tab','\t',1).data;

The latter would work in GNU octave in addition to Matlab.

